Release 10.1A: OpenEdge Getting Started:
Object-oriented Programming
Data member scoping in classes and procedures
Classes support the same definitions for variables, buffers, queries, temp-tables, and ProDataSets as procedures do, with one difference. That difference is the access modifier
PRIVATE,PUBLIC, orPROTECTED. Because of this difference, these built-in types are referred to as data members when they are used in classes. For more information on what access modes are valid for each type of data member definition, see the "Defining data members within a class" section. By default, all data members arePRIVATE.As with methods, the
PROTECTEDoption lets you define data members accessible throughout the class hierarchy but not from outside it. It also lets you use data member definitions throughout the hierarchy without having to repeat the definitions in each class that uses them.Comparison with procedure-based programming
Variables and other types of data definitions are also implicitly
PRIVATEwhen used in procedures. You can achieve something like thePROTECTEDcapability using procedures by defining variables and other types of data asNEWSHAREDin a parent procedure and asSHAREDin a subprocedure. Shared data elements require that the definitions be repeated asSHAREDin each subprocedure that shares them, which is typically done using an include file containing all of the definitions, so that they are guaranteed to match in all procedures that use them. You can achieve something similar toPUBLICdata members usingGLOBALSHAREDvariables and other data elements, with the key difference that whilePUBLICdata members are scoped to the class that defines them, once a variable or other data element is defined asGLOBALSHAREDit remains allocated for the duration of the session and cannot be deleted.
|
Copyright © 2005 Progress Software Corporation www.progress.com Voice: (781) 280-4000 Fax: (781) 280-4095 |